/* eslint-disable @typescript-eslint/no-explicit-any */
import { BrowserWindow, dialog } from 'electron'

export default function createMenuOpts (): any[] {
  return [
    {
      label: '文件', // 一级菜单名称
      submenu: [ // 定义子菜单
        {
          label: '新建',
          click: function () {
            console.log('点击事件')
          }
        },
        {
          label: '打开新窗口',
          accelerator: 'CmdOrCtrl+n', // 添加快捷键
          click: () => { // 添加点击事件
            let win: BrowserWindow | null = new BrowserWindow({
              width: 640,
              height: 480,
              webPreferences: { nodeIntegration: true }
            })
            win.loadURL('https://www.baidu.com')
            // win.loadFile('newWindow.html')
            win.on('closed', () => {
              win = null
            })
          }
        }
      ]
    },
    {
      label: '编辑',
      submenu: [
        { label: '剪切' },
        { label: '复制' }
      ]
    },
    {
      label: '帮助',
      role: 'help',
      submenu: [
        {
          label: '更多',
          click () {
            console.log('more')
          }
        },
        {
          label: '关于',
          // role: 'about',
          click () {
            dialog.showMessageBox({
              type: 'info',
              title: '关于',
              message: '当前应用信息'
            }).then((reply) => {
              console.log(reply.response)
            })
          }
        }
      ]
    }
  ]
}
